<?php
/**
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt or that can be found at 
 * http://code.google.com/p/billboardce/wiki/License.
 *
 * @package    YouTube_Data
 * @category   Model
 * @license    http://code.google.com/p/billboardce/wiki/License New BSD License
 * @version    SVN: $Id: $
 */
class YouTube_Data extends Ot_Db_Table
{
    /**
     * Name of the table in the database
     *
     * @var string
     */
    protected $_name = 'tbl_plugin_slidetype_youtube';
  
    /**
     * Primary key of the table
     *
     * @var string
     */
    protected $_primary = 'slideId';

    /**
     * Generates the form for adding and editing a slide's URL
     * 
     * @param array $values The values the form should be populated with
     * @return Zend_Form
     */
    public function form($values = array())
    {
        $form = new Zend_Form();
        $form->setAttrib('class', 'slideTypeForm')
             ->setDecorators(array(
                     'FormElements',
                     array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')),
                     'Form'
             ));
             
        $videoId = $form->createElement('text', 'videoId', array('label' => 'Video ID:'));
        $videoId->setValue(isset($values['videoId']) ? $values['videoId'] : '');
        
        $mute = $form->createElement('select', 'mute', array('label' => 'Mute Video:'));
        $mute->setMultiOptions(array(
                '0' => 'No',
                '1' => 'Yes'
               ))
             ->setValue(isset($values['mute']) ? $values['mute'] : '0');
             
        $volume = $form->createElement('select', 'volume', array('label' => 'Volume:'));
        
        for ($x = 0; $x <= 100; $x+=5) {
            $volume->addMultiOption($x, $x);
        }
        
        $volume->setValue(isset($values['volume']) ? $values['volume'] : '75');
        
        $form->addElements(array($videoId, $mute, $volume));

        $form->setElementDecorators(array(
                  'ViewHelper',
                  'Errors',
                  array('HtmlTag', array('tag' => 'div', 'class' => 'elm')),
                  array('Label', array('tag' => 'span')),
              ));
        
        return $form;
    }    
}